package xiu_xiu.view_Aa_sos;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;


import com.xiu_xiu.R;

import org.xutils.view.annotation.ViewInject;

import java.util.ArrayList;

import me.nereo.multi_image_selector.MultiImageSelectorActivity;
import xiu_xiu.base.BaseActivity;
import xiu_xiu.utils.ui.ToastUtil;
import xiu_xiu.utils.widget.AnimCheckBox;


/**
 * 发布需求页面
 */
public class SosIssueActivity extends BaseActivity implements AnimCheckBox.OnCheckedChangeListener {
    @ViewInject(R.id.research)
    private AnimCheckBox research;
    @ViewInject(R.id.other)
    private AnimCheckBox other;
    @ViewInject(R.id.car)
    private AnimCheckBox car;


    /**
     * 启动发布求救
     *
     * @param context
     */
    public static void startUi(Context context) {
        Intent intent = new Intent(context, SosIssueActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_help_issue);
        initView();
        setOnClickListener();
    }

    /**
     * 初始化view
     */
    private void initView() {
        setTitleMore(View.VISIBLE, View.INVISIBLE, "发布求救", null, null, null);
        setBackArrows(findViewById(R.id.bar_top_conver_classify_back));
        research.setOnCheckedChangeListener(this);
        other.setOnCheckedChangeListener(this);
        car.setOnCheckedChangeListener(this);
    }

    /**
     * 设置点击事件
     */
    private void setOnClickListener() {

//        gridview.setAdapter(adapter);
    }

    /**
     * 处理监听
     */
    @SuppressWarnings("unused")
    private OnClickListener onClickListener = new OnClickListener() {

        @Override
        public void onClick(View v) {
            switch (v.getId()) {

                default:
                    break;
            }
        }
    };

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
    }

    @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        //获取选择的图片
        if (requestCode == 995 && resultCode == -1) {
            ArrayList<String> listData = data.getStringArrayListExtra(MultiImageSelectorActivity.EXTRA_RESULT);
            if (listData == null || listData.size() <= 0) {
                ToastUtil.getToastShort("文件获取失败");
                return;
            }
        }

    }

    /**
     * 类型的选择
     *
     * @param view
     * @param checked
     */
    @Override
    public void onChange(AnimCheckBox view, boolean checked) {
        if (view.getId() == R.id.other) {
            research.setChecked(!checked, true);
            car.setChecked(!checked, true);

        } else if(view.getId() == R.id.car){
            other.setChecked(!checked, true);
            research.setChecked(!checked, true);

        }else if(view.getId() == R.id.research){
            other.setChecked(!checked, true);
            car.setChecked(!checked, true);
        }
    }
}
